package qn.easywechat.web.controller;

import com.qn.web.qnwebbase.common.vo.ReturnResult;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import qn.common.web.JsonResult;
import qn.easywechat.service.ISysConigService;
import qn.easywechat.web.vo.request.GetSysConfigListRequest;
import qn.easywechat.web.vo.request.GetSysConfigRequest;
import qn.easywechat.web.vo.response.SysConfigListResponse;
import qn.easywechat.web.vo.response.SysConfigVo;

import javax.annotation.Resource;

@RestController
@RequestMapping("sysconfig")
public class SysConfigController {

    @Resource
    ISysConigService sysConigService;

    @ApiOperation(value = "获取配置信息列表")
    @RequestMapping(value = "getconfiglist", method = RequestMethod.POST)
    public JsonResult<SysConfigListResponse> getConfigList(@RequestBody GetSysConfigListRequest request) {
        JsonResult<SysConfigListResponse> result = new JsonResult<>();
        SysConfigListResponse response = sysConigService.getConfigList(request);
        return result.setData(response);
    }

    @ApiOperation(value = "获取配置信息")
    @RequestMapping(value = "/getSysConfig", method = RequestMethod.POST)
    public JsonResult<SysConfigVo> getSysConfig(@RequestBody GetSysConfigRequest request) {

        JsonResult<SysConfigVo> result = new JsonResult<>();
        SysConfigVo vo = sysConigService.getSysConfig(request);
        result.setData(vo);
        return result;
    }


    @ApiOperation(value = "保存配置信息")
    @RequestMapping(value = "/addSysConfig", method = RequestMethod.POST)
    public JsonResult<ReturnResult> addSysConfig(@RequestBody SysConfigVo vo) {
        ReturnResult res = sysConigService.addSysConfig(vo);
        JsonResult<ReturnResult> result = new JsonResult<ReturnResult>(res);
        return result;

    }
}
